// e4.groovy
/*
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91  99.

Find the largest palindrome made from the product of two 3-digit numbers.
*/
def isP(n) {
    (n % 10 != 0) && n.toString() == n.toString().reverse()
}

largestP = 0
(101..999).each { a ->
    (101..999).each { b ->
        def c = a * b
        if (100000 < c && c < 1000000 && isP(c) && c > largestP) largestP = c
    }
}

print "The largest palindrome made from the product of two 3-digit numbers is "
println "${largestP}."

